package com.cn
import scala.util.matching.Regex
//scala正则使用
object scala_re {
  def isMobileNumber(number: String): Boolean ={
    val regex = "^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))[0-9]{8}$".r
    val length = number.length
    regex.findFirstMatchIn(number.slice(length-11,length)) != None
  }


  def main(args: Array[String]): Unit = {
    val pattern = "Scala".r
    val str = "Scala is Scalable and cool"
    val phone1="13232231435 ".trim
    val phone3="13232231435 "
    val phone2="403252674"
    println(phone3)
    println(phone1)
    val tmp=isMobileNumber(phone1)
    println(tmp)
    println(pattern findFirstIn str)
  }
}
